Socket
Socket
Sign inDemoInstall

@lerna/package-graph

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lerna/package-graph

Lerna's internal representation of a package graph


Version published
Weekly downloads
553K
increased by3.23%
Maintainers
2
Weekly downloads
 
Created

What is @lerna/package-graph?

@lerna/package-graph is a utility for managing and analyzing the dependency graph of packages within a monorepo. It helps in understanding the relationships between different packages and can be used to perform operations like finding dependencies, dependents, and traversing the graph.

What are @lerna/package-graph's main functionalities?

Creating a Package Graph

This feature allows you to create a graph of packages from an array of package objects. The graph can then be used to analyze the relationships between the packages.

const { PackageGraph } = require('@lerna/package-graph');
const packages = [
  { name: 'package-a', version: '1.0.0', dependencies: { 'package-b': '^1.0.0' } },
  { name: 'package-b', version: '1.0.0', dependencies: {} }
];
const graph = new PackageGraph(packages);
console.log(graph);

Finding Package Dependencies

This feature allows you to find the dependencies of a specific package within the graph. In this example, it retrieves the dependencies of 'package-a'.

const { PackageGraph } = require('@lerna/package-graph');
const packages = [
  { name: 'package-a', version: '1.0.0', dependencies: { 'package-b': '^1.0.0' } },
  { name: 'package-b', version: '1.0.0', dependencies: {} }
];
const graph = new PackageGraph(packages);
const packageA = graph.get('package-a');
console.log(packageA.localDependencies);

Finding Package Dependents

This feature allows you to find the dependents of a specific package within the graph. In this example, it retrieves the dependents of 'package-b'.

const { PackageGraph } = require('@lerna/package-graph');
const packages = [
  { name: 'package-a', version: '1.0.0', dependencies: { 'package-b': '^1.0.0' } },
  { name: 'package-b', version: '1.0.0', dependencies: {} }
];
const graph = new PackageGraph(packages);
const packageB = graph.get('package-b');
console.log(packageB.localDependents);

Other packages similar to @lerna/package-graph

Keywords

FAQs

Package last updated on 20 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc